const moviesDao = require('../dao/moviesDAo')

module.exports = {
    async showMovies({
        cname,
        ename,
        types,
        area,
        poster,
        time,
        upDate,
        score,
        count,
        intro,
        isClassic,
        director,
        actor,
        images
    }) {
        if(cname!=null){
            return await moviesDao.addMoives({
                cname,
                ename,
                types,
                area,
                poster,
                time,
                upDate,
                score,
                count,
                intro,
                isClassic,
                director,
                actor,
                images,
            });
        }else{
            return {'code':0,'msg':'失败'}
        }
        
    },
    //查询所有
    async queryAll() {
        return await moviesDao.queryMoives();
    },

    //查询ID
    async queryOnly(id) {
        return await moviesDao.queryOnlys(id);
    },

     

    //查询分类
    async queryType(
        types
    ) {
        return await moviesDao.queryTypeMoives(
            types
        );
    },

   

    //删除
    async deleteMov({
        cname,
    }) {
        return await moviesDao.deleteMoives({
            cname,
        });
    },

    //修改
    async modifiedMoives({
        _id,
        cname,
        ename,
        types,
        area,
        poster,
        time,
        upDate,
        score,
        count,
        intro,
        isClassic,
        director,
        actor,
        images
    }) {
        return await moviesDao.updateMoives(
           { _id, 
            cname,
            ename,
            types,
            area,
            poster,
            time,
            upDate,
            score,
            count,
            intro,
            isClassic,
            director,
            actor,
            images
        });
    },
}